﻿Public Class clsJNJPB
    Public Function insert(en As entityJNJPB) As Integer
        Dim sql As String = String.Empty
        Dim rtn As Integer
        sql &= "INSERT INTO sf.b_gt_jnjpb(factory_id , technology_id, oper_date, jnj , batch , color , "
        sql &= "prec_stir , hs_yysg , hs_yysb , prec , xsj , nd , "
        sql &= "hs_pb, oper , update_time) "
        sql &= "VALUES ( ?, ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?, ?, (SELECT CURRENT_TIMESTAMP(6)))"
        With en
            rtn = DBacs.ExecuteUpdateSql(sql, -1, .factory_id, .technology_id, .oper_date, .jnj, .batch, .color,
                                         .prec_stir, .hs_yysg, .hs_yysb, .prec, .xsj, .nd,
                                         .hs_pb, .oper)
        End With
        Return rtn
    End Function

    Public Function update(en As entityJNJPB) As Integer
        Dim sql As String = String.Empty
        Dim rtn As Integer
        sql &= " UPDATE sf.b_gt_jnjpb SET oper_date = ?, jnj = ?, batch = ?, color = ?, prec_stir = ? "
        sql &= " , hs_yysg = ?, hs_yysb = ?, prec = ?, xsj = ?, nd = ?, hs_pb = ? "
        sql &= " WHERE sys_id = ? "
        With en
            rtn = DBacs.ExecuteUpdateSql(sql, -1, .oper_date, .jnj, .batch, .color, .prec_stir,
                                         .hs_yysg, .hs_yysb, .prec, .xsj, .nd, .hs_pb, .sys_id)
        End With
        Return rtn
    End Function

    Public Function selectBySysid(_sysid As String) As DataTable
        Dim szSql As String = "select a.*,b.requirement,b.control_point from sf.b_gt_jnjpb a left join sf.t_mst_technology b on a.technology_id::integer = b.sys_id where a.factory_id=? and a.sys_id=?"
        Return DBacs.ExecuteSql(szSql, -1, "TS", _sysid)
    End Function

    Public Function getList(startTime As String, endTime As String) As DataTable
        Dim szSql As String = ""
        szSql &= "select * from sf.b_gt_jnjpb "
        szSql &= " where 1=1 "
        If startTime <> "" Then
            szSql &= " and update_time >= '" + startTime + "'"
        End If
        If endTime <> "" Then
            szSql &= " and update_time <= '" + endTime + "'"
        End If
        Return DBacs.ExecuteSql(szSql, -1)
    End Function
End Class
